
//
//  HelpReimTableViewController.swift
//  HuaYun
//
//  Created by enghou on 2019/1/11.
//  Copyright © 2019 xyxorigation. All rights reserved.
//

import UIKit

class HelpReimTableViewController: BaseTableViewController {

    let datePicker = UIDatePicker(frame: CGRect.init(origin: CGPoint.zero, size: CGSize(width: UIScreen.main.bounds.size.width, height: 220)))
    let field = UITextField()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        datePicker.locale = Locale.init(identifier: "zh_CN")
        datePicker.backgroundColor = UIColor.white
        datePicker.datePickerMode = .date
        self.view.addSubview(field)
        field.inputView = datePicker
        field.inputAccessoryView = self.toolbarview
        let back = UIBarButtonItem.init(image: UIImage.init(named: "icon_nav_whiteback")!.withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(self.pop))
        back.tintColor = UIColor.white
        self.navigationItem.leftBarButtonItem = back
    }
    
    override func endedit() {
        super.endedit()
        let date = self.datePicker.date
        let scanner = ScanBinaryCodeViewController()
        scanner.date = date
        self.push(destination: scanner)
    }
    
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        switch indexPath.row {
        case 0:
            let bx = ReimbursementListViewController()
            bx.title = "报销列表"
            self.push(destination: bx)
            break
        case 1:
            let bx = AllReimburseListViewController()
            bx.title = "报销申请单列表"
            self.push(destination: bx)
            break
        default:
            self.field.becomeFirstResponder()
            break
        }
    }
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        let ifscan = User.scan
        if ifscan == true {
            return 3
        } else {
            return 2
        }
    }
    
    
    override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 10
    }
    
    
}
